﻿using T4UtilityBelt.DataDesigns;
using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Controls.Renderers.Android
{
    public class StringRenderer : PropertyRenderer<StringControl, IStringRenderer, StringProperty>, IStringRenderer
    {
        protected override void OnRenderUiXmlContentInput(StringControl control, CodeWriter writer)
        {
            writer.WriteBeginTag("EditText");
            RenderFirstElementAttributes(writer);
            RenderControlAttributes(control, writer);

            writer.AddBinding("Text", control.Text);
            writer.RenderBindingsAttribute();

            //writer.WriteAttribute("AcceptsReturn", control.AcceptsReturn);
            //writer.WriteAttributeFormat("Text", @"{{Binding {0},  Mode=TwoWay}}", GetBindingContext(control));
            //writer.WriteAttributeFormat("local:MvxBind", "{{'Text':{{'Path':'{0}'}}}}}}}}", GetBindingContext(control));

            writer.WriteFullEnd();
        }

        protected override void OnRenderUiXmlContentReadOnly(StringControl control, CodeWriter writer)
        {
            writer.WriteBeginTag("TextView");
            RenderControlAttributes(control, writer);

            writer.AddBinding("Text", control.Text);
            writer.RenderBindingsAttribute();

            //writer.WriteAttributeFormat("local:MvxBind", "{{'Text':{{'Path':'{0}'}}}}}}}}", GetBindingContext(control));
            writer.WriteFullEnd();
        }
    }
}